<?php 
/*
$JA#COPYRIGHT$
*/

// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.model' );
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jaconstants.php';
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'japermissions.php';
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jafunctions.class.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jahelper.php');
global $jbconfig;
component_configs();
checkPermission('view_list_profiles');

require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'models'.DS.'japrofiles.php');
require_once (dirname(__FILE__).DS.'helper.php');

$limit				= 	intval(trim( $params->get( 'number_items' )));
$mode				= 	trim( $params->get( 'mode', 'latest' ) );
$employer_list		= 	$params->get( 'employer_list', '' );
$is_hiring		= 	$params->get( 'is_hiring', 1 );

global $mainframe;
if(!defined('JAJOBBOARD_GLOBAL_CSS')){
	 global $mainframe;
	 if(file_exists(JPATH_BASE.DS.'templates/'.$mainframe->getTemplate().'/css/ja.jobboard.css')){
	 	JHTML::stylesheet('ja.jobboard.css', 'templates/'.$mainframe->getTemplate().'/css/');
	 }
	 else{
	 	JHTML::stylesheet('ja.jobboard.css', 'components/'. 'com_jajobboard' .'/css/');
	 }    	 	 
	 
	 JHTML::script('ja.jobboard.js', 'components/com_jajobboard/js/');
	 JHTML::script('joomla.javascript.js', 'includes/js/');
	 
	 define('JAJOBBOARD_GLOBAL_CSS', 1);
} 
	// If the template has a css override use it
JHTML::stylesheet('', modJAListEmployersHelper::getFile('ja.list_employers.css','modules/mod_jalist_employers/ja.list_employers/','templates/'.$mainframe->getTemplate().'/css/'));

JHTML::_('behavior.tooltip');

/* Requirement Cache*/
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jacache'.DS.'jacache.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jacache'.DS.'jajob.inc.php');
$cache = new JA_Cache($jbconfig['cache']->get('cache_base', JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'cache'), $jbconfig['cache']->get('cache_time', 5), $jbconfig['cache']->get('caching', true));
$cache_id = md5('mod_jalist_employers');
$cache_group = 'jaemployers';
if($cache->check_cache($cache_id, $cache_group)) return ;
else $oldlen = strlen(ob_get_contents());
/* End cache */


$model = new JobBoardModelJAprofiles();

$where_more = '';
if(!$mainframe->isAdmin()){
	$where_more = " and fl.admin_only!=1";
}


$this->fieldlist = $model->getFieldList($where_more);
//var_dump($this->fieldlist);

$this->all_items = modJAListEmployersHelper::get_list_profiles( $model, $mode, $employer_list, $is_hiring, $limit);
$this->pagination = null;
$this->Itemid = modJAListEmployersHelper::_findItem();

$path = JModuleHelper::getLayoutPath('mod_jalist_employers', 'default');
if (file_exists($path)) {
	require($path);
}


/* Set cache */
$maincontent = substr(ob_get_contents(), $oldlen);
if($maincontent){
	$cache->_cache->store($maincontent, $cache_id, $cache_group);		
}

?>